<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="7" :lg="8" :md="9" :sm="24">
            <a-form-item label="数据日期">
              <j-date placeholder="请选择数据日期" v-model="queryParam.sjrq" readOnly ></j-date>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px;display:none">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
<!--      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>-->
      <a-button @click="selectTables" type="primary">配置表格</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('上传的说明信息')">导出说明</a-button>
<!--      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">-->
<!--        <a-button type="primary" icon="import">导入</a-button>-->
<!--      </a-upload>-->
      <!-- 高级查询区域
      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query> -->
<!--      <a-dropdown v-if="selectedRowKeys.length > 0">-->
<!--        <a-menu slot="overlay">-->
<!--          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>-->
<!--        </a-menu>-->
<!--        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>-->
<!--      </a-dropdown>-->
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;display:none">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="bwdm"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)" >填写打回说明</a>
        </span>

      </a-table>
    </div>

    <jrsj-fill-explain-modal ref="modalForm" @ok="modalFormOk"></jrsj-fill-explain-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import JrsjFillExplainModal from './modules/JrsjFillExplainModal'
  import { getAction } from '@/api/manage'

  export default {
    name: 'JrsjFillExplainList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      JrsjFillExplainModal
    },
    data () {
      return {
        description: '填写说明信息管理页面',
        // 表头
        columns: [
          {
            title:'报文日期',
            align:"center",
            dataIndex: 'sjrq'
          },
          {
            title:'报文代码',
            align:"center",
            dataIndex: 'bwdm_dictText'
          },
          {
            title:'打回人',
            align:"center",
            dataIndex: 'dhr'
          },
          {
            title:'打回时间',
            align:"center",
            dataIndex: 'dhsj',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'填报人',
            align:"center",
            dataIndex: 'tbr'
          },
          {
            title:'填报时间',
            align:"center",
            dataIndex: 'tbsj',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'审核状态',
            align:"center",
            dataIndex: 'shzt'
          },
          {
            title:'审核人',
            align:"center",
            dataIndex: 'shr'
          },
          {
            title:'审核时间',
            align:"center",
            dataIndex: 'shsj',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/jrsjFillExplain/jrsjFillExplain/list",
          delete: "/jrsjFillExplain/jrsjFillExplain/delete",
          deleteBatch: "/jrsjFillExplain/jrsjFillExplain/deleteBatch",
          exportXlsUrl: "/jrsjFillExplain/jrsjFillExplain/exportXls",
          importExcelUrl: "jrsjFillExplain/jrsjFillExplain/importExcel",

        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      loadData(){
        this.loading = true;
        var that=this;
        let url = "/jrsjFillExplain/jrsjFillExplain/getMaxDate";
        getAction(url).then((res)=>{
          that.onClearSelected();
          that.loading = false;
          if(res.success){
            let params = that.getQueryParams();
            params['sjrq']=res.result;
            that.queryParam.sjrq=res.result;
            that.mloadData(1);
          }else{
            that.$message.warning(res.message);
          }
        });
      },
      selectTables(){

      },
      mloadData(arg) {
        if(!this.url.list){
          this.$message.error("请设置url.list属性!")
          return
        }
        this.selectedRowKeys=[];
        //加载数据 若传入参数1则加载第一页的内容
        if (arg === 1) {
          this.ipagination.current = 1;
        }
        var params = this.getQueryParams();//查询条件
        this.loading = true;
        var that=this;
        getAction(this.url.list, params).then((res) => {
          if (res.success) {
            //update-begin---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
            that.dataSource = res.result.records||res.result;
            if(res.result.total)
            {
              that.ipagination.total = res.result.total;
            }else{
              that.ipagination.total = 0;
            }
            //update-end---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
          }else{
            that.dataSource = []
            that.ipagination.total = 0;
          }
          if(res.code===510){
            that.$message.warning(res.message)
          }
          that.loading = false;
        })
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'bwdm',text:'报文代码'})
        fieldList.push({type:'string',value:'tbr',text:'填报人'})
        fieldList.push({type:'date',value:'tbsj',text:'填报时间'})
        fieldList.push({type:'string',value:'tbsmlj',text:'填写说明路径'})
        fieldList.push({type:'string',value:'txsmwj',text:'填写说明文件'})
        fieldList.push({type:'string',value:'shzt',text:'审核状态'})
        fieldList.push({type:'string',value:'shr',text:'审核人'})
        fieldList.push({type:'date',value:'shsj',text:'审核时间'})
        fieldList.push({type:'string',value:'dhr',text:'打回人'})
        fieldList.push({type:'date',value:'dhsj',text:'打回时间'})
        fieldList.push({type:'string',value:'smqx',text:'说明权限'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>